#include <core/types.h>
#include <autoconf.h>
//#include <arch/at91sam926x.h>

#include "uart_at91sam926x.h"


void GkUartWriteByte(BYTE c)
{
	__VOLATILE__ struct AT9261_Uart *puart = (struct AT9261_Uart *)AT91SAM926X_PA_DBGU;

	while (!(puart->dwCSR & 0x2)); 

	puart->dwTHR = c;
}

BYTE GkUartReadByte(void)
{
	__VOLATILE__ struct AT9261_Uart *puart = (struct AT9261_Uart *)AT91SAM926X_PA_DBGU;

	while (!(puart->dwCSR & 0x1)); 
   
	return puart->dwRHR;
}

//fixme: 
UINT32 GkGetUartStatus(void)
{
	__VOLATILE__ struct AT9261_Uart *puart = (struct AT9261_Uart *)AT91SAM926X_PA_DBGU;

	return puart->dwCSR & 0x1; // if 1 read, otherwise no
}

